package com.peng.sparktest.sparksql.antlr

import com.peng.sparktest.sparksql.sql.parser.{MyRuleLexer, MyRuleParser}
import org.antlr.v4.runtime.tree.ParseTree
import org.antlr.v4.runtime.{ANTLRInputStream, CommonTokenStream}

object AntlrTest {
  def main(args: Array[String]): Unit = {
    val lexer: MyRuleLexer = new MyRuleLexer(new ANTLRInputStream("{1,{2,3},4}")) //分词
    val tokenStream = new CommonTokenStream(lexer) //词
    val parser = new MyRuleParser(tokenStream)
    val tree: ParseTree = parser.myRuleInit() //调用入口方法
    println(tree.toStringTree(parser))
  }

}
